import java.util.Scanner;

public class password {
    private static final String password="123456";

    public static void login(String mypassword)throws LoginException{
        if(!mypassword.equals(new String(password))){}
        throw new LoginException("密码错误");
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入密码：");
        String myPassword=sc.nextLine();
        try {
            login(myPassword);
            System.out.println("密码正确");
        }
        catch (LoginException e) {
            System.out.println("登录失败："+e.getMessage());
        }
    }
}
